﻿@using CoralNode.Core.Entity.Domains.Site
@using CoralNode.Core.Entity.Enums
@using CoralNode.MvcClient.Helper
@using Coralcode.Base.Utils
@model CoralNode.Core.Entity.SearchQuerys.Site.SiteSearchQuery

@{
    ViewBag.Title = "Index";
}

@Html.IncludePage("CoralAdmin/site", "_Left", new { current = "site" })
<div id="pbody">
    <div class="extra">
        <div class="pbody_top">
            <span class="ico ico_setting_site"></span><span class="t t_c">系统设置&nbsp;&nbsp;/&nbsp;&nbsp;站点管理</span>
        </div>
        <div id="main">
            <div class="js_tabcnt">
                <div class="tablelist_style2" data-js="tabellist_style2">
                    <div class="funsearch p_1 pl_2 pr_2 extra_normal">
                        <a class="btn_5 f_l" href="/m/site/createSite">添加站点</a>
                        <div class="f_r">
                            <form method="POST" action="/m/site/listSite">
                                <span class="t_des f_l pt_0-5">站点名称：</span>
                                <label class="search f_l">
                                    @Html.TextBoxFor(m => m.Name, new { @class = "text w_18", @msg = "请输入关键字" })
                                    @Html.AntiForgeryToken()
                                    <input type="submit" value="" class="submit" /></label>
                            </form>
                        </div>
                    </div>
                    <table cellpadding="0" cellspacing="0">
                        <tr class="exclude">
                            <th width="100">站点logo</th>
                            <th>概览</th>
                            <th>主题</th>
                            <th>静态化</th>
                            <th width="100">状态</th>
                            <th width="140">操作</th>
                        </tr>
                        @foreach (SiteDomain item in ViewBag.SiteList.Items) {
                            <tr>
                                <td>
                                    @if (!string.IsNullOrEmpty(@item.Logo)) {
                                        <img src="@item.Logo" alt="@item.Name" class="border"/>
                                    } else {
                                        <img src="/Themes/CoralAdmin/_misc/images/defaultLogo.jpg" alt="@item.Name" class="border"/>
                                    }
                                </td>
                                <td>
                                    <p>@item.Name  [@item.LangCode]</p>
                                    <p>
                                        @item.Description
                                    </p>
                                </td>
                                <td>@item.ThemeCode</td>
                                <td>@(item.IsStatic ? "开启中" : "关闭中")</td>
                                <td>@EnumUtil.GetEnumDescription(SiteEnums.SiteStatus, item.Status)</td>
                                <td>
                                    <div class="fun">
                                        @if (item.Status == SiteEnums.SiteStatus.Management) {
                                            <a href="/m/sitesetting/">系统设置</a>
                                        } else {
                                            <a href="/m/site/editSite/@item.Id">管理站点</a>
                                            <a href="/m/site/deleteSite/@item.Id" class="js_delete">删除站点</a>
                                        }
                                    </div>
                                </td>
                            </tr>
                        }
                    </table>
                </div>
            </div>
        </div>
        <div id="pager">
            <div class="info_pg">共@(ViewBag.SiteList.TotalItems)条</div>
            <div class="list_pg">
                <a href="/m/site/listSite?@ViewBag.queryString&p=1" class="first">首页</a>
                @if (@ViewBag.SiteList.HasPreviousPage && @ViewBag.SiteList.TotalItems > 0) {
                    <a href="/m/site/listSite?@ViewBag.queryString&p=@ViewBag.SiteList.PreviousPageIndex" class="prev">
                        上一页</a>
                } else {
                    <a class="prev none">上一页</a>
                }
                @foreach (var i in @ViewBag.SiteList.PageArray) {
                    if (@i == @ViewBag.SiteList.CurrentPageIndex) {
                    <a class="current">@i</a>
                    } else if (@i == 0) {
                    <a class="more">…</a>
                    } else {
                    <a href="/m/site/listSite?@ViewBag.queryString&p=@i" href="#">@i</a>
                    }
                }
                @if (@ViewBag.SiteList.HasNextPage && @ViewBag.SiteList.TotalItems > 0) {
                    <a class="next" href="/m/site/listSite?@ViewBag.queryString&p=@ViewBag.SiteList.NextPageIndex">
                        下一页</a>
                } else {
                    <a class="next none">下一页</a>
                }
                <a class="last" href="/m/site/listSite?@ViewBag.queryString&p=@ViewBag.SiteList.TotalPages">
                    尾页</a>
                <!-- <span class="msg">跳转</span>
                    <input class="text" type="text" value="">
                    <span class="msg">页</span>-->
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $('.nav_left_style2').find('li').eq(0).addClass('current');
    });
</script>
